@charset "UTF-8";
// 目前这个函数没有使用
//@function colorToRgba($color, $alpha: 1.0) {
//  @return unquote("rgba(#{red($color)}, #{green($color)}, #{blue($color)}, #{$alpha})");
//}

// rgb 颜色转 hex
@function rgbToHex($rgbColor) {
  $ieHexStr: ie-hex-str($rgbColor);
  @return unquote('\##{str-slice($ieHexStr,4)}');
}

// rgba 颜色转 hex ,该函数是根据背景颜色来计算的。默认背景色是白色
@function rgbaToHex($rgbaColor, $background: rgb(255, 255, 255)) {
  @if ($rgbaColor) {
    $bgR: red($background);
    $bgG: green($background);
    $bgB: blue($background);

    $colorRed: red($rgbaColor);
    $colorGreen: green($rgbaColor);
    $colorBlue: blue($rgbaColor);
    $colorAlpha: alpha($rgbaColor);

    $rgbColor: rgb(
      (1 - $colorAlpha) * $bgR + $colorAlpha * $colorRed,
      (1 - $colorAlpha) * $bgG + $colorAlpha * $colorGreen,
      (1 - $colorAlpha) * $bgB + $colorAlpha * $colorBlue
    );
    @return rgbToHex($rgbColor);
  }
  @return $rgbaColor;
}
